package com.winbomb.simulife;

import android.util.Log;

import com.winbomb.simulife.util.ProbInvalidException;
import com.winbomb.simulife.util.ProbUtil;

public class Family {

	private static final float[] probs = new float[] { 0.005f, 0.015f, 0.08f, 0.2f, 0.4f, 0.2f,
			0.08f, 0.015f, 0.005f };
	private static final FamilyType[] families = new FamilyType[] { FamilyType.UP_UP,
			FamilyType.UP_MIDDLE, FamilyType.UP_DOWN, FamilyType.MIDDLE_UP,
			FamilyType.MIDDLE_MIDDLE, FamilyType.MIDDLE_DOWN, FamilyType.DOWN_UP,
			FamilyType.DOWN_MIDDLE, FamilyType.DOWN_DOWN };

	private FamilyType familyType;

	public Family() {

		familyType = FamilyType.MIDDLE_MIDDLE;
		try {
			int i = ProbUtil.testProbs(probs);
			familyType = families[i];
		} catch (ProbInvalidException e) {
			Log.w("SimuLife", "Default family type will be set, caused by" + e);
		}
	}

	public String toString() {
		return familyType.getDesc();
	}

	public FamilyType getFamilyType() {
		return familyType;
	}

	static class FamilyType {

		public static final FamilyType UP_UP = new FamilyType(9, "上上"); // 上上等级，达官显贵，非常有钱的人家。
		public static final FamilyType UP_MIDDLE = new FamilyType(7, "上中"); // 上中等级，
		public static final FamilyType UP_DOWN = new FamilyType(7, "上下"); // 上下等级，

		public static final FamilyType MIDDLE_UP = new FamilyType(6, "中上"); // 中上等级
		public static final FamilyType MIDDLE_MIDDLE = new FamilyType(5, "中中"); // 中中等级
		public static final FamilyType MIDDLE_DOWN = new FamilyType(4, "中下"); // 中下等级

		public static final FamilyType DOWN_UP = new FamilyType(3, "下上"); // 下上等级
		public static final FamilyType DOWN_MIDDLE = new FamilyType(2, "下中"); // 下中等级
		public static final FamilyType DOWN_DOWN = new FamilyType(1, "下下"); // 下下等级

		private int level;
		private String desc;

		private FamilyType(int level, String desc) {
			this.level = level;
			this.desc = desc;
		}

		public int getLevel() {
			return level;
		}

		public String getDesc() {
			return desc;
		}

	}

}
